package com.cm.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cm.course.entity.ConsolidateQuestion;
import com.cm.course.mapper.ConsolidateQuestionMapper;
import com.cm.course.service.ConsolidateService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

/**
 * @author xdf
 * @date 2023-06-21
 */
@Service
public class ConsolidateServiceImpl implements ConsolidateService {
  @Resource ConsolidateQuestionMapper consolidateQuestionMapper;

  @Override
  public Page<ConsolidateQuestion> getConsolidateQuestionByPointOrDifficulty(
      String point, String difficulty, Long current, Long size) {
    Page<ConsolidateQuestion> page = new Page<>(current, size);
    QueryWrapper<ConsolidateQuestion> consolidateQuestionQueryWrapper = new QueryWrapper<>();
    // 0表示任意难度或者知识点
    consolidateQuestionQueryWrapper
        .eq(!"0".equals(point), "que_point", point)
        .eq(!"0".equals(difficulty), "que_difficulty", difficulty);
    consolidateQuestionMapper.selectPage(page, consolidateQuestionQueryWrapper);
    return page;
  }
}
